﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
        <%
        string f=(Request["f"]==null?"":Request["f"].ToString());
        %>
 <!--login-->
<div class="bg_box w_980">
	<div class="login_box">
		<h2>会员登录</h2>
        <div class="login_box_main">
        	<ul>
            	<li><label>账号：</label><input id="u_name" type="text" /></li>
            	<li><label>密码：</label><input id="u_pass" type="password" /></li>
                <li class="login_box_tip"></li>
            </ul>
            <a href="javascript:void(0);" title="登录" id="btnLogin" class="btn_login">登录</a>
        </div>
    </div>
</div>
<script language="javascript" type="text/javascript">
 
    function checkFrom() {
        var username = $("#u_name").val();
        var pwd = $("#u_pass").val();
        if (username == '' || pwd == '') {
            $(".login_box_tip").html("请您输入完整的登录信息"); 
            return false;
        } else {
            return true;
        }
    }

    function _login(from) {
        if (checkFrom()) {
            $.ajax({
                type: "post",
                url: "/login/userlogin.html",
                data: { uname: $("#u_name").val(), upass: $("#u_pass").val() },
                success: function (data, textStatus) {
                    if (data == 1) {
                        $(".login_box_tip").html("用户名不能为空");
                    }
                    else if (data == 2) {
                        $(".login_box_tip").html("密码不能为空");
                    }
                    else if (data == 3) {
                        $(".login_box_tip").html("该帐号已在别处登录，请务重复登录");
                    }
                    else if (data == 4) {
                        $(".login_box_tip").html("用户名或密码错误");
                    }
                    else if (data == 5) {
                        $(".login_box_tip").html("您帐号已经被管理员列入黑名单");
                    }
                    else if (data == 6) {
                        if (from == null || from == "")
                            window.location.href = "/vipcenter/basic.html"; //跳个人首页
                        else
                            window.location.href = from;
                    }
                    else {
                        $(".login_box_tip").html("登录失败");
                    }
                }
            });
        }
    }
    $(document).ready(function () {
        var _form = "<%=f%>";
        $("#btnLogin").click(function(){
            _login(_form);
        });
        $("#u_name").keydown(function (e) { 
            if (e.which == 13) 
                _login(_form); 
        });
        $("#u_pass").keydown(function (e) { 
            if (e.which == 13) 
                _login(_form); 
        });
    });
</script>

</asp:Content>
